package com.aspose.cells;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

class zbpf implements zahz {
   private boolean a;
   private int b;
   private HashMap c = new HashMap();
   private ArrayList d = new ArrayList();

   public zbpf(boolean var1, int var2) {
      this.a = var1;
      this.b = var2;
   }

   public zagu a() {
      if (this.c.size() == 0) {
         return zzb.a;
      } else {
         int var1 = 0;
         Iterator var4;
         Object var5;
         int var6;
         if (this.b < 2) {
            double var7 = 0.0D;
            var4 = this.d.iterator();

            while(var4.hasNext()) {
               var5 = var4.next();
               var6 = (Integer)this.c.get(var5);
               if (var6 > var1) {
                  var1 = var6;
                  var7 = (Double)var5;
               }
            }

            if (var1 < 2) {
               return zzb.a;
            } else {
               return new zyy(var7);
            }
         } else {
            double[] var2 = new double[this.b];
            int var3 = 0;
            var4 = this.d.iterator();

            while(var4.hasNext()) {
               var5 = var4.next();
               var6 = (Integer)this.c.get(var5);
               if (var6 > var1) {
                  var1 = var6;
                  var2[0] = (Double)var5;
                  var3 = 1;
               } else if (var6 == var1 && var3 < this.b) {
                  var2[var3] = (Double)var5;
                  ++var3;
               }
            }

            if (var1 < 2) {
               return zzb.a;
            } else if (var3 <= 1) {
               return new zyy(var2[0]);
            } else {
               zagu[][] var8 = new zagu[var3][];

               for(int var9 = 0; var9 < var3; ++var9) {
                  var8[var9] = new zagu[]{new zyy(var2[var9])};
               }

               return new zyt(var8);
            }
         }
      }
   }

   public boolean a(zagu var1, boolean var2) {
      return var2 && var1.b() == 12;
   }

   public zagu a(zagu var1, zaay var2, boolean var3) {
      var1 = var1.e(var2);
      switch(var1.b()) {
      case 0:
         if (this.a) {
            return zyw.a;
         }

         return var1;
      case 3:
         double var4 = ((zyy)var1).k();
         Object var6 = this.c.get(var4);
         if (var6 != null) {
            this.c.put(var4, (Integer)var6 + 1);
         } else {
            this.c.put(var4, 1);
            com.aspose.cells.b.a.a.ze.a(this.d, (Object)var4);
         }

         return null;
      case 12:
         if (var3) {
            return zyw.a;
         }

         return zzg.a;
      default:
         return (zagu)(var3 ? zyw.a : zzg.a);
      }
   }

   public zagu a(zagu var1, zaay var2, boolean var3, int var4) {
      var1 = var1.e(var2);
      switch(var1.b()) {
      case 0:
         if (this.a) {
            return zyw.a;
         }

         return var1;
      case 3:
         double var5 = ((zyy)var1).k();
         Object var7 = this.c.get(var5);
         if (var7 != null) {
            this.c.put(var5, (Integer)var7 + var4);
         } else {
            this.c.put(var5, var4);
            com.aspose.cells.b.a.a.ze.a(this.d, (Object)var5);
         }

         return null;
      case 12:
         if (var3) {
            return zyw.a;
         }

         return zzg.a;
      default:
         return (zagu)(var3 ? zyw.a : zzg.a);
      }
   }
}
